home *** CD-ROM | disk | FTP | other *** search
- /*
- TIFF Window Reader Program
- By: Jim Griffin
- Indianapolis, IN
- IJDG400 @ Indycms.bitnet.edu
- JimGriffin on America On Line
-
- Copyright ⌐ 1990 by Jim Griffin
-
- This program may not be sold or given away for profit.
- Feel free to distribute the program and source code among your friends,
- but all files must be included in the exchange.
- Keep all the files together.
- All rights reserved.
-
-
-
- I wrote this program to teach myself about intricacies of creating Offscreen CGrafPorts
- and reading TIFF files.
- I don't claim that this program demonstrates the best method of creating and displaying
- Offscreen CGrafPorts, merely that this is one of the ways. Feel free to use the knowledge
- you learn here in other programs you may write. My only desire is that you will
- release your code so that others may also gain new knowledge in programing Macintosh
- computers.
-
- To create this program I made extensive modifications to the code from
- the "ShowOff" source code in the Developer's Source Code library that
- is in America Online.
-
-
- NOTE: I assume that you will have a copy of Inside Macintosh Vols 1 thru 5 handy.
- If not then you might have difficulty understanding some of the color
- routines such as GetColor();, GetAuxWin(aWindow, &some_new_colors);, and
- all the rest.
- I also assume that you will understand C statements that look like
-
- (**(**some_new_colors).awCTable).ctTable[0].value = 0;
-
- If the above statement makes your eyes cross, then perhaps this program
- isn't for you. On the other hand if you want to learn how use statements
- like that then you should try to read the program.
- */
-
-
- #define NO_COLOR_QUICKDRAW 19601
- #include "my color.h"
- #include <OSUtil.h>
-
- main() /*main program*/
- {
- SysEnvRec what_is_there;
- CWindowPtr who_is_in_front;
- extern CGrafPort the_picture;
-
-
- init_color_demo(); /* initialize the Managers, prepare for program execution */
- SysEnvirons(2, &what_is_there);
- if(what_is_there.hasColorQD == FALSE) /* This program must have Color
- QuickDraw to function, else it
- would crash and that would be
- bad. Note that I only need
- Color QuickDraw, and not
- necessarily a color monitor.
- This program
- will run correctly on any
- macintosh with color Quickdraw,
- even an SE/30 which is obviously
- a Black and White machine.
- Color QuickDraw will allow for
- the Black and White environment
- and display the TIFF file in a
- surprisingly good manner. you
- just don't get color. */
- {
- StopAlert(NO_COLOR_QUICKDRAW, 0L);
- return;
- }
-
- OpenWindow(); /*start with one open window,
- OpenWindow will call my TIFF reader routine*/
-
- /* Main event loop */
- do
- {
- SystemTask();
- who_is_in_front = (CWindowPtr)FrontWindow();
-
- if (!menusOK && (who_is_in_front == nil))
- {
- DisableItem (myMenus [fileM], closeItem);
- DisableItem (myMenus [editM], 0);
- menusOK = true;
- }
- if (GetNextEvent(everyEvent,&myEvent))
- switch (myEvent.what)
- {
-
- case mouseDown:
- do_mouse_down(&myEvent);
- break;
- case keyDown:
- case autoKey:
- if ((myEvent.modifiers & cmdKey) != 0)
- DoCommand(MenuKey(myEvent.message & charCodeMask));
- break;
-
- case activateEvt:
- do_activate(&myEvent);
- break;
-
- case updateEvt:
- do_update(&myEvent);
- break;
-
- } /*switch myEvent.what*/
-
- }
- while (!doneFlag);
- ShowCursor(); /* Make certain the cursor is visible */
- while(who_is_in_front = (CWindowPtr)FrontWindow()) /* Close ALL the open Windows!!! */
- KillWindow(who_is_in_front);
-
-
- return;
- } /*end of the main program modual*/
-
-
-
-
-